<!DOCTYPE html>
<html lang="zh-CN"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>管理员列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/style/admin.css" media="all">
	<link rel="stylesheet" href="/style/list.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
				<div class="layui-inline" style="float:right">
					<button class="layui-btn layuiadmin-btn-admin" data-type="add" onclick="WinOpenAdd();">添加</button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">

            <table class="layui-hide" id="test"></table>

            <script type="text/html" id="barDemo">
                <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail"  onclick="WinOpenEdit({{d.id}})">编辑</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" onclick="WinOpenDel({{d.id}})">删除</a>
            </script>

        </div>
    </div>
</div>
<script src="/layui/layui.js"></script>
<script src="/layui/jquery.min.js"></script>
<style>
    .layui-body{overflow-y: scroll;}	
	.laytable-cell-1-orderId{width:50px;}
</style>
<script>
    var table;
    layui.use('table', function(){
        table = layui.table
            ,form = layui.form;

        table.render({
            elem: '#test'
            ,url:'/admin?url=Admin%2FList'
			,cellMinWidth:80
            ,cols: [[
                {type:'numbers'}
                ,{type: 'checkbox'}
                ,{field:'id',width:60,title:'ID'}
                ,{field:'us', title:'管理员编号'}
				,{field:'name',title:'管理员姓名'}
				,{field:'role',title:'管理角色'}
                ,{field:'state',title:'状态'}
				,{field:'edit',width:250, title:'编辑', templet: '#barDemo', unresize: true}
            ]]
            ,id: 'testReload'
        });

        //监听表格复选框选择
        table.on('checkbox(demo)', function(obj){
            console.log(obj)
        });


    });


    function createTime(v){
        return new Date(parseInt(v)).toLocaleString()
    }
    /**重写toLocaleString方法*/
    Date.prototype.toLocaleString = function() {
        var y = this.getFullYear();
        var m = this.getMonth()+1;
        m = m<10?'0'+m:m;
        var d = this.getDate();
        d = d<10?("0"+d):d;
        var h = this.getHours();
        h = h<10?("0"+h):h;
        var M = this.getMinutes();
        M = M<10?("0"+M):M;
        var S=this.getSeconds();
        S=S<10?("0"+S):S;
        return y+"-"+m+"-"+d+" "+h+":"+M+":"+S;}

	/*添加管理员*/
	function WinOpenAdd(){
		window.parent.WinOpenAdd(this,"/admin/admin/add.html","添加管理员",330,330,1);
	}	
	
	/*编辑管理员*/
	function WinOpenEdit(id){
		window.parent.WinOpenEdit(this,"/admin/admin/edit.html?id="+id,"修改管理员资料",330,330,1);
	}
	
	/*删除管理员*/
	function WinOpenDel(categoryId){
		window.parent.WinOpenEdit(this,"/admin/admin/del.html?id="+id,"删除管理员",340,300,1);
	}
	
	/*修改管理员状态*/
	function WinStatus(categoryId){
		layer.msg('确定修改吗？', {
			btn: ['确定', '取消']
			,yes: function(index, layero){
				layer.msg("更新数据:"+index);
			}
		});
	}
	
	/*查看管理员图片*/
	function WinPic(pic){
		layer.msg("<img src='"+pic+"' width='300' height='300' />");
	}
	
    function SelectData() {
        //数据刷新
		/*
		var orderStatus=$('#orderStatus').val();
		var payStatus=$('#payStatus').val();
		var deliveStatus=$('#deliveStatus').val();
		var orderNo=$('#orderNo').val();
        var userNo = $('#userNo').val();
        var userName = $('#userName').val();
		var phone=$('#phone').val();
		var url="/category/category/category.js?";
		if(orderStatus>0)
		{
			url+="orderStatus="+orderStatus+"&";
		}
		if(payStatus>0)
		{
			url+="payStatus="+payStatus+"&";
		}
		if(deliveStatus>0)
		{
			url+="deliveStatus="+deliveStatus+"&";
		}
		if(orderNo!="")
		{
			url+="orderNo="+orderNo+"&";
		}
		if(userNo!="")
		{
			url+="userNo="+userNo+"&";
		}
		if(userName!="")
		{
			url+="userName="+userName+"&";
		}
		if(phone!="")
		{
			url+="phone="+phone+"&";
		}
		*/
		alert(url);
        //执行重载
        table.reload('testReload', {
            url:url,
            page: {
                curr: 1 //重新从第 1 页开始
            }
        });
    }
	
</script>


</body>
</html>